package com.ecoolex.ying.space.ws;

import java.util.Date;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.framework.common.exception.BizException;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;
import com.ecoolex.ying.space.core.manager.PushMessageManager;
import com.ecoolex.ying.space.core.manager.PushMessageReadStateManager;
import com.ecoolex.ying.space.entity.PushMessage;

@Service
public class PushMessageServiceImpl implements PushMessageService{
	
	@Autowired
	private PushMessageManager pushMessageManager;

	@Override
	public PushMessage addPushMessage(PushMessage record, String createUser) throws BizException {
		return pushMessageManager.add(record, createUser);
	}

	@Override
	public PushMessage editPushMessage(PushMessage record, String updateUser) throws BizException {
		return pushMessageManager.edit(record, updateUser);
	}

	@Override
	public void deletePushMessage(PushMessage record, String updateUser) throws BizException {
		pushMessageManager.delete(record, updateUser);
	}

	@Override
	public PushMessage getPushMessageById(Integer id) {
		return pushMessageManager.getById(id);
	}

	@Override
	public Pagination<PushMessage> queryPushMessage(String title, Date startTime, Date endTime, Sorting[] sorts, Page page) {
		return pushMessageManager.query(title, startTime, endTime, sorts, page);
	}

	@Override
	public Pagination<PushMessage> queryPushMessageForH5(Date now, Page page) {
		return pushMessageManager.queryForH5(now,page);
	}

	@Override
	public Pagination<PushMessage> getPushMessageByReleaseUserIdForH5(Integer releaseUserId,Page page) {
		return pushMessageManager.getByReleaseUserIdForH5(releaseUserId,page);
	}
	
	@Override
	public Integer unreadCount(Integer readUserId,Integer releaseUserId) {
		return pushMessageManager.unreadCount(readUserId,releaseUserId);
	}
	
	@Autowired
	private PushMessageReadStateManager pushMessageReadStateManager;

	@Override
	public boolean updatePushMessageReadState(Integer readUserId,Integer releaseUserId, String updateUser) {
		return pushMessageReadStateManager.update(readUserId,releaseUserId, updateUser);
	}

}
